package january.test_1_24;

public class Solution {
    public int MoreThanHalfNum_Solution (int[] numbers) {
        // write code here
        int tmp = numbers[0];
        int count = 0;
        for (int i = 0; i < numbers.length; i++) {
            if(tmp == numbers[i]) {
                count++;
            } else if(count > 0) {
                count--;
            } else {
                tmp = numbers[i];
                count++;
            }
        }
        return tmp;
    }
}
